package com.study.demo.aop.demo1_2.config;

import com.study.demo.aop.demo1_2.annotation.EnableLogging;
import com.study.demo.aop.demo1_2.config.ProxyLogConfiguration;
import org.springframework.context.annotation.AdviceMode;
import org.springframework.context.annotation.AdviceModeImportSelector;
import org.springframework.context.annotation.AutoProxyRegistrar;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: elvin
 * @time: 2019-10-16 13:12
 * @desc:
 **/
public class LogConfigurationSelector extends AdviceModeImportSelector<EnableLogging> {
    @Override
    protected String[] selectImports(AdviceMode adviceMode) {
        List<String> result = new ArrayList<>();
        //注册 org.springframework.aop.config.internalAutoProxyCreator --> InfrastructureAdvisorAutoProxyCreator
        result.add(AutoProxyRegistrar.class.getName());
        //注册代理配置
        result.add(ProxyLogConfiguration.class.getName());
        return StringUtils.toStringArray(result);
    }
}
